// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the CONTROLLERLIB_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// CONTROLLERLIB_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#define CONTROLLERLIB_API __declspec(dllexport)

#include <string>
#include <assert.h>
#include <fstream>
#include <math.h>
using namespace std;


#define MAXSIZE 1024*4
char dataBuff[MAXSIZE];

int Hex2Dec(string hexStr)
{
	assert(hexStr.length()>0);


	int dec=0;
	int base=16;
	int j=0;
	for(int i=hexStr.length()-1;i>=0;i--)
	{
		int h=tolower(hexStr[i]);
		if(h<='9'&&h>='0')
		{
			h=h-'0';
		}
		else if(h<='f'&&h>='a')
		{
			h=h-'a'+10;
		}
		else
		{
			return -1;
		}
		h=h<<(4*j);
		dec=h|dec;
		j++;
	}
	return dec;
}

bool ParseHexLine(string line);

bool ReadHexFile(string path=".\\extend.dat");

extern "C"
CONTROLLERLIB_API bool __stdcall GetExternData(int nZone,unsigned long lunSize,BYTE* byBuff);

extern "C"
CONTROLLERLIB_API char* GetDataBuffer(char* path);

